home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / util / cli / rebootscript.lha / Rebootscript / RunScript.S < prev    next >
Text File  |  2000-08-24  |  3KB  |  119 lines

  1. ;******************************************************************************
  2. ; Run script/exe if Writescript was used previously.
  3. ; (Compiled with AsmPro V1.16d)
  4. ;
  5. ; Place this exe-file first in your startup-sequence.
  6. ;
  7. ; (c) Per Johansson aka Olle^Omen / Latex, Craze, Planet Jazz, Massive
  8. ;
  9. ;         omen@telia.com        http://go.to/olle    (2000-08-23)
  10. ;******************************************************************************
  11.  
  12.         incdir    Includes:
  13.         include Exec/Exec.I
  14.         include Exec/Exec_Lib.I
  15.  
  16.         include Dos/Dos_Lib.I
  17.  
  18. Start        lea.l    Pathbuffer,a1
  19.  
  20.         move.l    #Readname,d1        ; Open file
  21.         bsr.w    _Dos_Openfile
  22.  
  23.         move.l    #Pathbuffer,d2        ; Fetch path
  24.         move.l    #256,d3
  25.         bsr.w    _Dos_Read
  26.  
  27.         bsr.w    _Dos_Closefile        ; Close file
  28.  
  29.         move.l    #Readname,d1        ; Delete it
  30.         bsr.w    _Dos_Delete
  31.  
  32.         lea.l    Pathbuffer,a0        ; Check that it's not zero
  33.         tst.b    (a0)
  34.         beq.w    .q
  35.  
  36.         move.l    #Pathbuffer,d1        ; Execute!
  37.         bsr.w    _Dos_Execute
  38.  
  39.         move.l    #128,d1            ; Wait a little while
  40.         bsr.w    _Dos_Delay
  41.  
  42.         bsr.w    Reset            ; And reset afterwards if need
  43. .q        rts
  44.  
  45.  
  46. ; HWREF-Reset
  47.  
  48. Reset        move.l    $4.w,a6
  49.         cmp.w    #36,LIB_VERSION(a6)
  50.         blt    .oldexec
  51.         jmp    -726(a6)
  52. .oldexec    lea.l    .goaway(pc),a5
  53.         jsr    _LVOSupervisor(a6)
  54.         rts
  55.         even
  56. .goaway        lea.l    MAGIC_ROMEND,a0
  57.         sub.l    MAGIC_SIZEOFFSET(a0),a0
  58.         move.l    4(a0),a0
  59.         subq.l    #2,a0
  60.         reset
  61.         jmp    (a0)
  62.  
  63.  
  64.         Xdef    _Dos_Openfile
  65.         Xdef    _Dos_Closefile
  66.         Xdef    _Dos_Read
  67.         Xdef    _Dos_Write
  68.         Xdef    _Dos_Delete
  69.         Xdef    _Dos_Execute
  70.         Xdef    _Dos_Getsize
  71.         inclink    .asm:lo/dos.lnk
  72.  
  73.  
  74. ;+----------------------------------------------------------------------------+
  75. ;|         APrintf - Print's the string in a0 to stdout (could be pipe'd)       |
  76. ;|                                          |
  77. ;| In: A0 = String to print!                              |
  78. ;|                                          |
  79. ;| Thrashes no registers                              |
  80. ;+----------------------------------------------------------------------------+
  81.  
  82. APrintf        movem.l    d0-d7/a0-a6,-(sp)
  83.         move.l    a0,-(Sp)        ; Save Textpointer
  84.         moveq.l    #0,d0            ; Any version.
  85.         lea.l    .PDosName(Pc),a1
  86.         CALLEXEC OpenLibrary
  87.         move.l     d0,.PDosBase
  88.         beq.w    .Fail
  89.         move.l     (Sp)+,a0        ; Restore Textpointer
  90.         move.l     a0,a1
  91.         moveq.l     #0,d3            ; Calculate Size
  92. .Srch        tst.b     (a0)+
  93.         beq.w     .Fnd
  94.         addq.l     #1,d3
  95.         bra.w     .Srch
  96. .Fnd        move.l   .PDosBase(Pc),a6
  97.         jsr     _LVOOutput(a6)        ; Get Stdout
  98.         move.l     d0,d1            ; File (Stdout)
  99.         move.l     a1,d2            ; Text pointer
  100.         jsr     _LVOWrite(a6)        ; (File=D1,Data=D2,Length=D3)
  101.         move.l     .PDosBase(Pc),a1
  102.         CALLEXEC CloseLibrary
  103. .Fail        movem.l    (sp)+,d0-d7/a0-a6
  104.         rts
  105.  
  106. .PDosBase    dc.l    0
  107. .PDosName    dc.b    'dos.library',0
  108.         even
  109.  
  110. Readname    dc.b    's:rebootscript.bat',0    ; Filename to read.
  111.         even
  112.  
  113. MAGIC_ROMEND    =    $01000000
  114. MAGIC_SIZEOFFSET=    -$14
  115.  
  116.         section    buffers,bss_p
  117.  
  118. Pathbuffer    ds.b    256
  119.